package com.aizhixin.test.question.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.aizhixin.test.question.dto.QuestionDTO;
import com.aizhixin.test.question.service.QuestionService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping(value="/v1/open/anserQuestion")
@Api(tags="答题API")
@Slf4j 
public class AnserQuestionController {
	@Autowired
	private QuestionService questionService;
	@GetMapping(value="/",produces = MediaType.APPLICATION_JSON_VALUE)
	@ApiOperation(httpMethod="GET",value="随机抽一道题，并且答题",
	notes="随机抽一道题，并且答题<br><br><b>@author xixi</b>")
	public QuestionDTO getQuestionRandom() {
		QuestionDTO m=questionService.getRandomQuestion();
		return m;
	}
	
	@GetMapping(value="/{questionId}",produces = MediaType.APPLICATION_JSON_VALUE)
	@ApiOperation(httpMethod="GET",value="输入一个题号，显示这个题的相关信息",
	notes="输入一个题号，显示这个题的相关信息<br><br><b>@author xixi</b>")
	public QuestionDTO getQuestionByQuestionId
	(@ApiParam(value="题号",required=true)
	@PathVariable int questionId) {
		QuestionDTO m=questionService.getquestionById(questionId);
		return m;
	}

	
}
